package org.ycy.data.generator.enums;

import lombok.Getter;
import org.ycy.data.generator.generator.DoubleRandomGenerator;
import org.ycy.data.generator.generator.IGenerator;
import org.ycy.data.generator.generator.NumberRandomGenerator;
import org.ycy.data.generator.generator.StringRandomGenerator;

/**
 * @ClassName ValueType
 * @Description TODO
 * @Author 原长友
 * @Date 2023/3/3 23:53
 * @Version 1.0
 **/
@Getter
public enum ValueType {

    /**
     * 枚举类型
     */
    Integer("int", Integer.class),
    /**
     * 枚举类型
     */
    Long("long", Long.class),
    /**
     * 枚举类型
     */
    String("string", String.class),
    /**
     * 枚举类型
     */
    Enum("enum", Enum.class),
    /**
     * 双精度浮点型
     */
    Double("double", Double.class);

    /**
     * 类型code
     */
    private String code;
    /**
     * 类型类
     */
    private Class clazz;


    ValueType(String code, Class clazz) {
        this.code = code;
        this.clazz = clazz;
    }

    public IGenerator buildRandomGenerator() {
        switch (this) {
            case String:
                return new StringRandomGenerator();
            case Long:
            case Integer:
                return new NumberRandomGenerator();
            case Double:
                return new DoubleRandomGenerator();
            case Enum:
                throw new RuntimeException("暂不支持此Enum随机方式");
        }
        return null;
    }
}
